
import 'package:json_annotation/json_annotation.dart';
part 'request_sms_api.g.dart';

/// 请求模型
@JsonSerializable()
class RequestSmsApi {
  final String phoneNumber;
  final int type;

  RequestSmsApi({required this.phoneNumber, required this.type}); 

  

  Map<String, dynamic> toJson() => _$RequestSmsApiToJson(this);
}

/// 响应模型: //该请求结构特殊，msg仅标记请求是否成功，不能代表短信是否发送成功。sussess代表是否发送成功，Message\":真正的业务错误信息
/// {"code":200,"msg":"操作成功","data":{"accessDeniedDetail":"{\"Message\":\"手机号码格式错误\",\"RequestId\":\"FA437962-0AB8-5939-9328-6F878C5D4C6E\",\"Code\":\"isv.MOBILE_NUMBER_ILLEGAL\"}","message":"Error","model":null,"code":"Error","success":false}}

@JsonSerializable()
class AccessDeniedDetail {
  // 使用 @JsonKey 匹配 JSON 中的大写字母开头的 key
  @JsonKey(name: 'Message')
  final String message;

  @JsonKey(name: 'RequestId')
  final String requestId;

  @JsonKey(name: 'Code')
  final String code;

  AccessDeniedDetail({
    required this.message,
    required this.requestId,
    required this.code,
  });

  factory AccessDeniedDetail.fromJson(Map<String, dynamic> json) =>
      _$AccessDeniedDetailFromJson(json);

  Map<String, dynamic> toJson() => _$AccessDeniedDetailToJson(this);
}

@JsonSerializable(
  explicitToJson: true, // 因为 accessDeniedDetail 是一个复杂对象，所以需要这个
)
class ResponseSmsApi {
  
  final AccessDeniedDetail? accessDeniedDetail;

  final String? message;
  final String? code;
  final bool success;
  
  ResponseSmsApi({
    this.accessDeniedDetail,
    this.message,
    this.code,
    required this.success,
  });

  factory ResponseSmsApi.fromJson(Map<String, dynamic> json) =>
      _$ResponseSmsApiFromJson(json);

  Map<String, dynamic> toJson() => _$ResponseSmsApiToJson(this);
}


